﻿using Function;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using UI.Permission;
using UI.UserControl.Base;

namespace UI.UserControl.UI
{
    public partial class DMLButtonAction : DMLButtonEntity
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //检查权限
                Buttons = Buttons.ToLower();
                if (Buttons.Contains("add"))
                {
                    if (!RightCheck.HavePermission(RightCheck.permissionType.Add))
                    {
                        Buttons = Buttons.Replace("add", "");
                    }
                }
                if (Buttons.Contains("query"))
                {
                    //查询
                    if (!RightCheck.HavePermission(RightCheck.permissionType.Query))
                        Buttons = Buttons.Replace("query", "");
                }
                var uriPath = Request.Url.AbsolutePath;
                uriPath = uriPath.Substring(0, uriPath.LastIndexOf('/') + 1);
                linknew.NavigateUrl = uriPath + AddPage;
                linkquery.NavigateUrl = uriPath + QueryPage;
                linkbackup.NavigateUrl = uriPath + BackupPage;

                if (Buttons.Contains("add"))
                {
                    linknew.Visible = true;
                }
                if (Buttons.Contains("query"))
                {
                    linkquery.Visible = true;
                }
                if (BackupButtonVisible)
                {
                    linkbackup.Visible = true;
                }
            }
        }
    }
}